#ifndef LOD_VERTEX_H
#define LOD_VERTEX_H
#include <vector>
#include <cmath>
#include <iostream>

class vertex
{
    public:
    float xyz[3];
    float normal[3];

    //todo should be a property of a vector
    bool normalize_normalv()
    {
        float length = std::sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]);
        if(length!=0.0f)
        {
            if(length!=1.0f) {
               normal[0] /= length;
               normal[1] /= length;
               normal[2] /= length;
            }
            return true;
        }
        else
           return false;
    }

   bool operator== (vertex const& v) const
   {
      /*if(xyz[0]!=v.xyz[0])
         std::cout<<"aa\n";
      if(xyz[1]!=v.xyz[1])
         std::cout<<"bb\n";
      if(xyz[2]!=v.xyz[2])
         std::cout<<"cc\n";
      if(normal[0]!=v.normal[0])
         std::cout<<"dd\n";
      if(normal[1]!=v.normal[1])
         std::cout<<"ee\n";
      if(normal[2]!=v.normal[2])
         std::cout<<"ff\n";*/
      return (xyz[0]==v.xyz[0] &&
              xyz[1]==v.xyz[1] &&
              xyz[2]==v.xyz[2] &&
              normal[0]==v.normal[0] &&
              normal[1]==v.normal[1] &&
              normal[2]==v.normal[2]);
   }
};

class tvertex : public vertex
{
    public:
    std::vector<int> triangles;
    int tcount;

    bool operator== (tvertex const& tv) const
    {
       // call operator== from the base class
       if(((vertex*)this)->operator==(tv) == false)
          return false;
       return (triangles==tv.triangles && 
               tcount==tv.tcount);
    }
};
#endif
